using System;
using System.Xml;

namespace Mehat.San.SanFS
{
	public enum EDataStoreStrategyType
	{
		XmlFile,
		SqlLite
	}
	
	public class DataStoreFactory
	{
		public static IDataStoreStrategy CreateStrategy(XmlNode CfgNode)
		{
			XmlNode	tgt = CfgNode.Attributes.GetNamedItem("Strategy");
			
			if (tgt == null)
				throw new Exception("No 'Strategy' element found");

			EDataStoreStrategyType	tgtData = (EDataStoreStrategyType) Enum.Parse(typeof(EDataStoreStrategyType), tgt.Value);
			
			if (tgtData == EDataStoreStrategyType.SqlLite)
				return new SqlLiteDataStoreStrategy(CfgNode);
			else
				throw new Exception(String.Format("Strategy '{0}' is not supported", tgt.Value));
		}
	
	}  // END CLASS
}  // END NAMESPACE
